package net.gamebug.guessthemovie;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class Scores extends Activity {

    public ListView viewnames;
    public ListView viewscores;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.scores);

        ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this, R.layout.rowleft, R.id.labelleft);
        viewnames = (ListView) findViewById(R.id.viewnames);
        
        ArrayAdapter<Integer> adapter2 = new ArrayAdapter<Integer>(this, R.layout.rowright, R.id.labelright);
        viewscores = (ListView) findViewById(R.id.viewscores);

        bd b = new bd(this);
        b.open();
        Cursor c = b.getTop5Scores();
        int position = 1;
        if (c.moveToFirst()) {
            do {
                if (position == 6)
                    break;
                System.out.println(c.getString(0) + "-" + c.getInt(1));
                adapter1.add(position + "  -  " + c.getString(0));
                adapter2.add(c.getInt(1));
                position++;
            } while (c.moveToNext());
        }
        c.close();
        b.close();
        viewnames.setAdapter(adapter1);
        viewscores.setAdapter(adapter2);
    }
}